using System;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Games
/// </summary>
namespace Reviewer.Games
{
    public static class Games
    {
        public static int GameCount(int SpilID)
        {
            
            ReviewerMySql SQL = new ReviewerMySql();
            string Dato = DateTime.Now.ToShortDateString();
            string SQLs = "";
            OdbcDataReader reader = SQL.ExecuteReader("SELECT * FROM V2_SpilViews WHERE SpilID = " + SpilID + " AND Dato = '" + Dato + "'");
            if (reader.Read())
            {
                SQLs = "UPDATE V2_SpilViews SET Views = Views+1 WHERE SpilID = " + SpilID + " AND Dato = '" + Dato + "'";
            }
            else 
            {
                SQLs = "INSERT INTO V2_SpilViews(SpilID, Dato, Views) VALUES(" + SpilID + ",'" + Dato + "',1)";
            }
            SQL.ExecuteNonQuery(SQLs);
            
            return 0;
        }

        public static int LastUpdated(string SpilID)
        {
            ReviewerMySql SQL = new ReviewerMySql();
            string Dato = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString();
            SQL.ExecuteNonQuery("UPDATE V2_Spil SET UpdateDato DATE = " + Dato + "WHERE SpilID = '" + SpilID + "'");
            return 0;
        }
    }
}
